///////////////////////////////////////////////////////////////////////////////
//
//  Elfin
//  Kolonitsky Developers Alliance (c) 2011
//  All rights received
//
///////////////////////////////////////////////////////////////////////////////

package controller
{
    import flash.system.Capabilities;
    import flash.system.Security;

    import model.ElfinProxy;

    import view.AppPreloader;
    import view.PreloaderMediator;

import mx.resources.ResourceManager;

    import org.kolonitsky.alexey.StoredFieldManager;
    import org.kolonitsky.alexey.mvcext.view.ContainerMediator;

    import org.puremvc.as3.interfaces.INotification;
    import org.puremvc.as3.patterns.command.SimpleCommand;

    import org.kolonitsky.alexey.debug.DebugWrapper;

    public class StartUpCommand extends SimpleCommand
    {
        override public function execute(notification:INotification):void
        {
            DebugWrapper.useBrowserConsole = true;
            DebugWrapper.trace("INFO: " + Config.APPLICATION_NAME + " v" + Config.VERSION);
            DebugWrapper.trace("INFO: CMD > StartupCommand");
            DebugWrapper.trace("INFO: System language: " + Capabilities.language);

            Security.allowDomain("*");

            var preloader:AppPreloader = notification.getBody() as AppPreloader;

            // register required proxies for store application settings
            facade.registerProxy(new ElfinProxy());
            facade.registerMediator(new PreloaderMediator(preloader));
            facade.registerMediator(new ContainerMediator());

            ResourceManager.getInstance().localeChain = [ "ru_RU", "en_US" ];
            StoredFieldManager.instance.initialize(Config.APPLICATION_NAME);
        }
    }
}
